$(document).ready(function() {

    
function ticker1Dim () {
    var boxWidth = $('.ntic span.title').width();
    //alert(boxWidth);
    $('.ntic .wrap_t').css('width', 974-boxWidth+'px');
}
ticker1Dim ();


function ticker2Dim () {
    var boxWidth = $('#ticker_v3 span.title').width();
    //alert(boxWidth);
    $('#ticker_v3 #viewport').css('width', 935-boxWidth+'px');
}
ticker2Dim ();

function ticker3Dim () {
    var boxWidth = $('#ticker_v7 span.title , #ticker_v8 span.title').width();
    //alert(boxWidth);
    $('#ticker_v7 .wrap_t , #ticker_v8 .wrap_t').css('width', 994-boxWidth+'px');
}
ticker3Dim ();




// ticker settings
var newsTickerObj=$('.newsticker').nTicker();
var newsTickerObjVer=$('.liveticker').nTicker({vertical: true});
$(".nticker").newsTicker();



$('#decrease_button')
    .mousedown( function() { newsTickerObj.nTicker('setSpeed', -3); } )
    .mouseup( function() { newsTickerObj.nTicker('setSpeed', 1); } )
    .click( function() { return false; } ) ;
    
$('#increase_button')
    .mousedown( function() { newsTickerObj.nTicker('setSpeed', 3); } )
    .mouseup( function() { newsTickerObj.nTicker('setSpeed', 1); } )
    .click( function() { return false; } ) ;
    
//add class to last list element
    
    if($.browser.msie && $.browser.version=="6.0")
    {
        $('.container_12 .clear>div:first-child').addClass('alpha');
        $('#wether_vidget li:first-child').addClass('first');
        $('select.select_style').removeClass('select_style').addClass('select_ie');
        $('#ra_slider li div.box:last-child').addClass('lastbox');
        $('#radar_backpage_sub .clear div.box:last-child').addClass('lastbox');
    }
    
    if($.browser.msie && $.browser.version=="7.0")
    {
        $('.container_12 .clear>div:first-child').addClass('alpha');
        $('#wether_vidget li:first-child').addClass('first');
        $('#ra_slider li div.box:last-child').addClass('lastbox');
        $('#radar_backpage_sub .clear div.box:last-child').addClass('lastbox');
    }
    
    if($.browser.msie && $.browser.version=="8.0")
    {
        $('#header .shade .inner').addClass('important');
    }
    
// slider setup
    $("#slider_tv1").easySlider({
        vertical: true,
        prevId: 'prevBtn1',
        nextId: 'nextBtn1',
        continuous:        true
    });    
    
    $("#slider_tv2").easySlider({
        vertical: true,
        prevId: 'prevBtn2',
        nextId: 'nextBtn2'
    });    
    
    $("#slider_tv3").easySlider({
        vertical: true,
        prevId: 'prevBtn3',
        nextId: 'nextBtn3'
    });    
    
    $("#slider_tv4").easySlider({
        vertical: true,
        prevId: 'prevBtn4',
        nextId: 'nextBtn4'
    });        
    
    $("#slider_tv5").easySlider({
        vertical: true,
        prevId: 'prevBtn5',
        nextId: 'nextBtn5'
    });
    
    $("#slider_tv6").easySlider({
        vertical: true,
        prevId: 'prevBtn6',
        nextId: 'nextBtn6'
    });    

    $("#slider_gall .gutter").easySlider({
        prevId: 'prevBtnGall',
        nextId: 'nextBtnGall'
    });    
    
    $("#mini_multimedia .mm_slider").easySlider({
        prevId: 'prevBtnMm',
        nextId: 'nextBtnMm'
    });    
    
    $("#medium_multimedia .mm_slider").easySlider({
        prevId: 'prevBtnMm',
        nextId: 'nextBtnMm',
        numeric: true,
        numericId:'mm_controls'
    });    
    
    $("#large_multimedia .mm_slider").easySlider({
        prevId: 'prevBtnLmm',
        nextId: 'nextBtnLmm',
        numeric: true,
        numericId:'lmm_controls'
    });
    $('#large_multimedia ol#lmm_controls li:first a').addClass('first');
    $('#large_multimedia ol#lmm_controls li:last a').addClass('last');
    
    /*
    $('#mini_video_block .video_slider').each(function (i) {
        i = i+1;
        $(this).addClass('v_slide_multi_'+i);
        $('.v_slide_multi_'+i).easySlider({
            prevId: 'prevBtnG'+i,
            nextId: 'nextBtnG'+i
        });
    });
    */
    
    $("#top_nik_block .nik_slider").easySlider({
        prevId: 'prevBtnNik',
        nextId: 'nextBtnNik'
    });
    
    $("#day_slider .slider").easySlider({
        prevId: 'prevBtnDay',
        nextId: 'nextBtnDay',
        firstId: 'firstBtnDay',
        lastId: 'lastBtnDay',
        firstShow: false,    
        lastShow: false
    });
    
    $("#user_frontpage_slider .uf_slider").easySlider({
        prevId: 'prevBtnUf',
        nextId: 'nextBtnUf'
    });
    
    
    $("#ws_box").easySlider({
        nextId : "ws_box_next",
        prevId : "ws_box_prev",
        numeric : true,
        numericId : 'ws_controls',
        auto: true,
        continuous: true,
        pause:            3000
    });
    
    $("#ra_slider").easySlider({
        nextId: "ra_next",
        prevId: "ra_prev",
        numeric: true,
        numericId:'ra_controls'
    });
    
    $(".liveslider").easySlider({
        vertical:         true,
        controlsShow:     false,
        continuous:        true, 
        auto:            true,
        pause:             5000        
    });

    


    
    /*
    $('#slider_gall').hover(
    function() { 
        $('.btnLarge').removeClass('displaynone'); 
        },
    function() { 
        $('.btnLarge').addClass('displaynone'); 
        });
    */
    



//second level 
    /*
    $('#nav_main li').hover(
    function() { $('ul', this).css('display', 'block'); },
    function() { $('ul', this).css('display', 'none'); });
    $('#tohome').hover(
    function() { $('a.tv', this).css('display', 'block'); },
    function() { $('a.tv', this).css('display', 'none'); });
    var config = {    
         sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
         interval: 200, // number = milliseconds for onMouseOver polling interval    
         over: goDown, // function = onMouseOver callback (REQUIRED)    
         timeout: 300, // number = milliseconds delay before onMouseOut    
         out: goUp // function = onMouseOut callback (REQUIRED)    
    };
    */
    
    function goDown () {
        $('ul.nav_sec', this).css('display', 'block');
        $(this).children('.main_cat').not('.search a').addClass('hover');
        newsTickerObj.nTicker('setSpeed', 0);
    }
    function goUp () {
        $('ul.nav_sec', this).css('display', 'none');
        $(this).children('.main_cat').removeClass('hover');
        newsTickerObj.nTicker('setSpeed', 1);
    }
    
    function goDownH () {
        $('a.tv', this).css('display', 'block');
        $(this).children('a.home').addClass('hover_home');
        newsTickerObj.nTicker('setSpeed', 0);
    }
    function goUpH () {
        $('a.tv', this).css('display', 'none');
        $(this).children('a.home').removeClass('hover_home');
        newsTickerObj.nTicker('setSpeed', 1);
    }
    
    function goDownBL () {
        $('a.tv', this).css('display', 'block');
        newsTickerObj.nTicker('setSpeed', 0);
    }
    function goUpBL () {
        $('a.tv', this).css('display', 'none');
        newsTickerObj.nTicker('setSpeed', 1);
    }
    
    $("#nav_main li").hoverIntent
    ({
        sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
        interval: 200, // number = milliseconds for onMouseOver polling interval    
        over: goDown, // function = onMouseOver callback (REQUIRED)    
        timeout: 300, // number = milliseconds delay before onMouseOut    
        out: goUp // function = onMouseOut callback (REQUIRED)  
     })
    
    $('#tohome').hoverIntent
    ({
        sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
        interval: 200, // number = milliseconds for onMouseOver polling interval    
        over: goDownH, // function = onMouseOver callback (REQUIRED)    
        timeout: 300, // number = milliseconds delay before onMouseOut    
        out: goUpH // function = onMouseOut callback (REQUIRED)  
     })
    
    $('#brand_logo').hoverIntent
    ({
        sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
        interval: 200, // number = milliseconds for onMouseOver polling interval    
        over: goDownBL, // function = onMouseOver callback (REQUIRED)    
        timeout: 300, // number = milliseconds delay before onMouseOut    
        out: goUpBL // function = onMouseOut callback (REQUIRED)  
     })

// to article submeni
    /*$('ul.nav_sec span.arrow').hover(
    function() 
    { 
        $(this).parent().next('ul.nav_toarticle').css('display', 'block'); 
        $(this).parent().addClass('ar_hover');
    },
    function() 
    { 
        if ( $(this).parent().next('ul.nav_toarticle').hover() )
        {
            return false;
        }
        else
        {
            $(this).parent().next('ul.nav_toarticle').css('display', 'none');
            $(this).parent().removeClass('ar_hover');
        }
    });
    
    $('ul.nav_toarticle').hover(
    function() { 
                $(this).css('display', 'block');
                $(this).prev('a').addClass('ar_hover');
               },
    function() { 
                $(this).css('display', 'none'); 
                $(this).prev('a').removeClass('ar_hover');
               });
    

*/
// fast search    
    $('#nav_main li.search a').click(function() { 
        if ( $(this).hasClass('open_fs') )
        {
            $('#fast_search').animate({ height: '0px' }, 500, function() 
                { 
                    $('#fast_search').css('display','none');
                    $('#nav_main li.search a').removeClass('open_fs');
                });
        }
        else
        {
            $('#fast_search').show().animate({ height: '51px' }, 500, function()
                { 
                    $('#fast_search').css('display','block'); 
                    $("#fast_search input.text").focus();
                });
            $(this).addClass('open_fs');
        }
    });
    
    


    

// add class to last item
    $('ul#top_this_week li:last-child').addClass('last');
    $('ul#top_commented li:last-child').addClass('last');
    $('ul#partner_sites li:last-child').addClass('last');
    $('ul#top_recomended li:last-child').addClass('last');
    $('.info_tabs ul.nav li:last-child').addClass('last');    
    $('.master_tabs>ul>li:last-child').addClass('last');    
    $('.info_tabs .slider_tv dl dd:last-child').addClass('last');    
    $('.outer_tabs .cont_out ul li:last-child').addClass('alt');    
    $('.related_list dd:last-child').addClass('last');
    $('.hit_plus_sidebar h3:first-child').addClass('first');
    $('#other_media dd:last-child').addClass('last');
    $('dl.stat dd p:last-child').addClass('last');
    $('dl.data dd:last-child').addClass('last');
    $('dl.input_data dd:last-child').addClass('last');
    $('#backpage_section #hit_plus div:last-child').addClass('last_grid');
    $('#mypage ul.badges_list li .badge:last-child').addClass('blast');
    $('#mypage ul.mp_karma_list li:last-child').addClass('last');
    
    
    $('ul.links').each(function(i){
        $(this).children('li:first').addClass('fila')
        $(this).children('li:empty').addClass('fila');
    });
    
    /*
    if ( $('.info_tabs ul.nav li:last-child').attr('class') == 'extra' )
    {
        $('.info_tabs ul.nav li:last-child').prev('li').addClass('last');    
    }
    else
    {
        $('.info_tabs ul.nav li:last-child').addClass('last');    
    }
    */
    
//sequential-list
    $('#top_commented li').each(function (i) {
        i = i+1;
        $(this).addClass('item'+i);
    });
    
    $('#top_recomended li').each(function (i) {
        i = i+1;
        $(this).addClass('item'+i);
    });    

    
//add class to every second .info_block in #span_left
    /*
    if($("#horoskop_nav").length){ 
        $("#horoskop_nav li").each(function(i){ var remainder = (i + 1) % 4; 
            if(remainder === 0){ $(this).addClass("last"); } }); 
        }
    */


//  extra hover section    
    $('ul.comment_item').hover(
    function() { $(this).children('li.rating').addClass('rating_hover'); },
    function() { $(this).children('li.rating').removeClass('rating_hover'); });
    
    $('ul#top_this_week li').hover(
    function() { $(this).addClass('hover'); },
    function() { $(this).removeClass('hover'); });
    
    $('ul#top_commented li').hover(
    function() { $(this).addClass('hover'); },
    function() { $(this).removeClass('hover'); });    
    
    $('dl.data dd').hover(
    function() { $(this).addClass('hover'); },
    function() { $(this).removeClass('hover'); });

    $('dl.data dt').hover(
    function() { $(this).next('dd').addClass('hover'); },
    function() { $(this).next('dd').removeClass('hover'); });
    
    
    $('ul.tl_time_block>li').live('mouseover mouseout', function(event) {
      if (event.type == 'mouseover') {
        $(this).addClass('hover');
      } else {
        $(this).removeClass('hover');
      }
    });
    
    
    $('dl#other_media dt').hover(
    function() { $(this).next('dd').addClass('om_hover'); },
    function() { $(this).next('dd').removeClass('om_hover'); });    
    
    $('#rss_table tr').hover(
    function() { $(this).children('td').addClass('hover'); },
    function() { $(this).children('td').removeClass('hover'); });    

//    šlager hover help
    $('.breaking a.img').hover(
    function() { $(this).parent('.breaking').addClass('breaking_hover'); },
    function() { $(this).parent('.breaking').removeClass('breaking_hover'); });
    
    $('#hit_alpha a.photo').hover(
    function() { $(this).parent().children().children('a.title').addClass('t_hover'); },
    function() { $(this).parent().children().children('a.title').removeClass('t_hover'); });    
    
    $('#hit_alpha a.title').hover(
    function() { $(this).parent().parent().children('a.photo').addClass('p_hover'); },
    function() { $(this).parent().parent().children('a.photo').removeClass('p_hover'); });    

    $('#hit_beta a.photo').hover(
    function() { $(this).parent().children().children('a.title').addClass('t_hover'); },
    function() { $(this).parent().children().children('a.title').removeClass('t_hover'); });
    
    $('#hit_beta a.title').hover(
    function() { $(this).parent().parent().children('a.photo').addClass('p_hover'); },
    function() { $(this).parent().parent().children('a.photo').removeClass('p_hover'); });
    
    $('#hit_alpha .txtbo').hover(
    function() { $(this).addClass('txt_hover'); },
    function() { $(this).removeClass('txt_hover'); });
    
    $('#hit_alpha .txtcl').hover(
    function() { $(this).addClass('txt_hover'); },
    function() { $(this).removeClass('txt_hover'); });
    
    $('#hit_alpha .box_1-4vert').hover(
    function() { $(this).addClass('box_hover'); },
    function() { $(this).removeClass('box_hover'); });    
    
    $('#hit_plus a.photo').hover(
    function() { $(this).next().children('a.title').addClass('t_hover'); },
    function() { $(this).next().children('a.title').removeClass('t_hover'); });    
    
    $('#hit_plus a.title').hover(
    function() { $(this).parent().prev('a.photo').addClass('p_hover'); },
    function() { $(this).parent().prev('a.photo').removeClass('p_hover'); });
    
    $('#hit_alpha .breaking .title a').hover(
    function() { $(this).parent().prev('.overtitle').addClass('ot_hover'); },
    function() { $(this).parent().prev('.overtitle').removeClass('ot_hover'); });
    
    $('.widget_slider').hover(
    function() { $(this).addClass('ws_hover'); },
    function() { $(this).removeClass('ws_hover'); });    
    
    $('.side_box a.photo').hover(
    function() { $(this).parent().children().children('a.title').addClass('t_hover'); },
    function() { $(this).parent().children().children('a.title').removeClass('t_hover'); });    
    
    $('.side_box a.title').hover(
    function() { $(this).parent().parent().children('a.photo').addClass('p_hover'); },
    function() { $(this).parent().parent().children('a.photo').removeClass('p_hover'); });    
    
    $('#anketa_block .wrap_photo').hover(
    function() { $(this).addClass('show_nav'); },
    function() { $(this).removeClass('show_nav'); });
    
    $('#radar_backpage #ra_slider a.photo, #radar_backpage_sub a.photo').hover(
    function() { $(this).next('a.text').addClass('ra_hover'); },
    function() { $(this).next('a.text').removeClass('ra_hover'); });
    
    $('.radar_anketa .wrap_photo').hover(
    function() { $(this).parent().children().children('h3.title a').addClass('t_hover'); },
    function() { $(this).parent().children().children('h3.title a').removeClass('t_hover'); });    
    
    /*
    $('#toplist_block ul.list>li').live('mouseover mouseout', function(event) {
      if (event.type == 'mouseover') {
        $(this).addClass('hover');
      } else {
        $(this).removeClass('hover');
      }
    });
    */


// Tabs
    $('.tabs').tabs();
    $('.master_tabs').tabs();
    

// Special select
    jQuery('.select_style').select_skin();
    $('dl.input_data .cmf-skinned-select').eq(0).addClass('cmf_skinned_small');
    $('dl.input_data .cmf-skinned-select').eq(1).addClass('cmf_skinned_small');    
    $('dl.input_data .cmf-skinned-select').eq(2).addClass('cmf_skinned_medium');
    
    $(".browse_style input, #mypage input.file").filestyle({ 
         image: "/www/images/primary/browse-button.png",
         imageheight : 30,
         imagewidth : 81,
         width : 175
     });
    
    $('.browse_button').hover(
    function() { 
                    $(this).addClass('bb_hover')
                    $(this).prev('input').addClass('bs_hover');
                },
    function() { 
                    $(this).removeClass('bb_hover')
                    $(this).prev('input').removeClass('bs_hover');
                });    


// kamo.hr more block
    $('#kamohr .more').click(function() {
        $(this).parent('p').next('div.expanded').show()
        $(this).hide();
        return false;
    });
    
    $('#kamohr .close').click(function() {
        $(this).parents('div.expanded').hide()
        $(this).parents('.block').find('a.more:hidden').show();
        return false;
    });

// search page
 $('.srp_nav .all a').click(function() {
  $(this).removeClass('uncheck')
  $('.srp_nav dd a:not(.all a)').addClass('uncheck')
  return false;
 });
 
 $('.srp_nav a:not(.all a)').click(function() {
  $(this).toggleClass('uncheck')
    
  var allUnchecked = true;
  $('.srp_nav a:not(.all a)').each(function(){
   if(!$(this).hasClass('uncheck')){allUnchecked = false}
  })
  //alert(allUnchecked)
  if(allUnchecked){
   $('.srp_nav dd.all a').removeClass('uncheck')
  }else{
   $('.srp_nav dd.all a').addClass('uncheck')
  }
  
  return false;
 }); 
 
 $('.srp_result li').hover(
 function() { $(this).addClass('hover'); },
 function() { $(this).removeClass('hover'); });

// fun carucell
    /*$('.games_slider .box').hover(
    function() { $(this).addClass('box_hover'); },
    function() { $(this).removeClass('box_hover'); });*/
    
    $('.game_list li').hover(
    function() { $(this).addClass('list_hover'); },
    function() { $(this).removeClass('list_hover'); });




//  notification remove
    
    $('#notification a.close').click(function() {
        $('#notification').animate({ 
                                   height: '0'
                                    }, 500, function(){ $(this).remove() })
                          
        $('.notification_HL').removeClass('notification_HL')
        return false;
    });

    
        //function fixedElements() {
            $(window).scroll( function() 
               { 
                    var artHeight = $('#article_tabs ul').height();
                    var arHeight = $('#article').height() - artHeight;
                    if ($.browser.msie){var position = document.documentElement.scrollTop;}
                    else {var position = window.pageYOffset;}
                    if (position < arHeight){$('#article_tabs ul').addClass('fix').removeClass('abs');}
                    if (position > arHeight){$('#article_tabs ul').addClass('abs').removeClass('fix');}
                    return true;                   
               
               } );

            $(window).scroll( function() 
               { 
                    //var headHeight = $('#header').height();
                    if ($.browser.msie){var position = document.documentElement.scrollTop;}
                    else {var position = window.pageYOffset;}
                    if (position > 1 ){$('#header .shade').fadeIn(500 );}
                    if (position < 1 ){$('#header .shade').fadeOut(800);}
                    return true;
               } );
            
            $(window).scroll( function() 
               { 
                    if ($.browser.msie){var position = document.documentElement.scrollTop;}
                    else {var position = window.pageYOffset;}
                    if (position > 1 ){$('#notification').addClass('displaynone');}
                    if (position < 1 ){$('#notification').removeClass('displaynone');}
                    return true;                                          
               } );
        //}
        //fixedElements();
        
//my page settings 
    $('.data_block a.edit').click(function() { 
                                           
        var data = $(this).parent().parent().children('dl.data_preview');
        var input_data = $(this).parent().parent().find('dl.data_input');
        if ( data.is(':visible') )
        {
            data.fadeOut( 500, function(){ input_data.fadeIn( 500 );    });
        }
        else
        {
            input_data.fadeOut( 500, function(){ data.fadeIn( 500 ); });
        }
        return false;
        
    });
    
    $('.edit_av_2').click(function(){
        $('.edit_avatar').trigger('click');
    });
    $('.edit_pass').click(function(){
        $('.edit_p').trigger('click');
    });    
    $('input.pass1').focus(function(){
        $('input.pass2').addClass('focused');
    });    
    

//  Table style setup
    $('.prog_block table tr:odd').addClass('odd');
    $('.prog_block table tr:even').addClass('even');
    
    $('.subscription table.rates tr:odd').addClass('odd');
    $('.subscription table.rates tr:even').addClass('even');
    
    // Sport league table enhance
    if($('table.league_table').length){ 
            $('table.league_table tr').not('table.league_table tr.stat').each(function(i) 
                { 
                    var remainder = (i + 2) % 2;
                    if(remainder === 0) { $(this).addClass('even') 
                } 
            }); 
        }    
        
    // team players enhance
    if($('.team_players div').length){ 
            $('.team_players div dl').each(function(i) 
                { 
                    var remainder = (i + 2) % 2;
                    if(remainder === 0) { $(this).addClass('even') 
                } 
            }); 
        }    
        
    $('table.league_table tr th:nth-child(odd)').addClass('todd');    
    $('table.league_table tr td:nth-child(odd)').not('table.league_table tr.stat td:nth-child(odd)').addClass('todd');
    
    $('table.league_table tr').not('table.league_table tr.stat').hover(
    function() { $(this).addClass('hover'); },
    function() { $(this).removeClass('hover'); });
    
    $('table.league_table tr').not('table.league_table tr.stat').click(function() { 
        $(this).toggleClass('active');
        $(this).next('tr.stat').toggle();
        return false;
    });
    
    // Sport league table STOP
    
    if($('#article_content .live_list').length){ 
            $('#article_content .live_list dd').not('#article_content .live_list dd.photo').each(function(i) 
                { 
                    var remainder = (i + 1) % 2;
                    if(remainder === 0) { $(this).addClass('even') 
                } 
            }); 
        }    
    
// tv program
    $('.prog_block a.prog_cont').click(function() { 
        $(this).parent().next('table').slideToggle();
        $(this).toggleClass('prog_cont_ex');
        return false;
    });


// toolbar
    $('#toolbar a.close').click(function() { 
        $(this).toggleClass('open');
        $('#toolbar .gutter').toggle();
        return false;
    });




// welcome owerlay
    
    function winDim () {
        var winHeight = $('body').height();
        var winWidth = $('body').width();
        $('#owerlay_block').css('height', winHeight+80+'px');
        $('#owerlay_block').css('width', winWidth+'px');
    }
    winDim ();
    
    $(window).bind('resize', resizeWindow);
        function resizeWindow( e ) {
        var newWindowHeight = $(window).height();
        var newWindowWidth = $(window).width();
        $('#owerlay_block').css('height', newWindowHeight );
        $('#owerlay_block').css('width', newWindowWidth );
    }
    
// toolbar width detection
    /*
    function winWidth () {
        var winWidth = $('body').width();
    }
    winWidth ();
    */
    
    $(window).bind('resize', resizeWindow);
        function resizeWindow( e ) {
        var newWindowWidth = $(window).width();
        if ( newWindowWidth <= 1178 )
        {
            $('#toolbar dl.serv').addClass('serv_mini');
        }
        else 
        {
            $('#toolbar dl.serv').removeClass('serv_mini');
        }
    }
    
    //alert($('body').width()); 1178


//

    $('#owerlay_block a.close').click(function() { 
        $('#owerlay_block').hide();
        return false;
    });
    
    $('#owerlay_block a.go').click(function(){
        $('#owerlay_block a.close').trigger('click');
    });
    
    $('#owerlay_block span.all').click(function() { 
        $('#owerlay_block a.close').trigger('click');
    });
    
    $('#feedback_button').click(function () {
        winDim ();
        $('#owerlay_block').show();
        $('#owerlay_block .inner').hide();
        $('#owerlay_block #fdb_block').show();
    });
    
    $('#feedback_toolbar').click(function () {
        winDim ();
        $('#owerlay_block').show();
        $('#owerlay_block .inner').hide();
        $('#owerlay_block #fdb_block').show();
    });
    
    $('#reg_head').click(function () {
        winDim ();
        $('#owerlay_block').show();
        $('#owerlay_block .inner').hide();
        $('#owerlay_block #reg').show();
    });
    
    $('#log_head').click(function () {
        winDim ();
        $('#owerlay_block').show();
        $('#owerlay_block .inner').hide();
        $('#owerlay_block #log').show();
    });
    
    $('#reg_tool').click(function(){
        $('#reg_head').trigger('click');
    });
    
    $('#log_tool').click(function() { 
        $('#log_head').trigger('click');
    });
    
    
//remove title attribte
    $('#nav_main li a').attr('title','');
    
    
    
//photo article
     if($('#photo_article').length > 0){
      $('#photo_article').masonry({
       singleMode: true, 
       itemSelector: '.box' 
      });

    $('#photo_article .box a').each(function(i){
       var imgHeight = $(this).next('img').height();
       $(this).height(imgHeight-10);
      });
     }

    

    
    
//side banner height
    /*
    function rollWrapSide () {
        var bHeight = $('.roll_banner_side .rollwrap embed').height();
        var iHeight = $('.roll_banner_side .rollwrap img').height();
        $('.roll_banner_side').height(iHeight);
        $('.roll_banner_side').height(bHeight);
    }
    rollWrapSide ();    
    */
    
    
    function centerFootUl () {
        var ulWid = $('#footer .f_bottom ul').width();
        var space = 974 
        var left = (space - ulWid) / 2
        $('#footer .f_bottom ul').css('left', left);
    }
    centerFootUl ();
    
    
    //site map

    
    $('#footer a.more').click(function() { 
        
        var more = $(this)
        var sitemap = $('#footer #site_map')
        
        if ( more.hasClass('opened') )
        {
            more.removeClass('opened');
            sitemap.hide();            
        }
        else
        {
            more.addClass('opened');
            sitemap.show();
        }
        return false;
    }).anchorAnimate();


// ie9 info bar
    $(window).scroll( function() 
    { 
        //var headHeight = $('#header').height();
        if ($.browser.msie){var position = document.documentElement.scrollTop;}
        else {var position = window.pageYOffset;}
        if (position > 1 ){$('#ie9_bar').fadeOut(5 );}
        if (position < 1 ){$('#ie9_bar').fadeIn(800);}
        return true;
    });


    var ie9Inst = $('#ie9_bar .inst');
    function openInst () 
    {
        ie9Inst.css('display','block');
        ie9Inst.animate({ top:'70px' }, 500).removeClass('inst_closed');
        ie9Inst.find('li.two').animate({ left:'328px' });
        ie9Inst.find('li.three').animate({ left:'656px' });
        $('.banner_area, .banner').css('visibility','hidden');
    };
    function closeInst () 
    {
        ie9Inst.animate({ top:'-468px' }, 500, function(){ ie9Inst.css('display','none'); }).addClass('inst_closed');
        ie9Inst.find('li.two').animate({ left:'0px' });
        ie9Inst.find('li.three').animate({ left:'0px' });
        $('.banner_area, .banner').css('visibility','visible');
    };

    $('.ie9_bar a.close').click( function() { 
        var ie9Bar = $(this).parent('.ie9_bar');
        ie9Bar.animate({ marginTop:'-70px'  }, 500, function(){ ie9Bar.css('display','none'); }).addClass('ie9bar_closed');
        $('.banner_area, .banner').css('visibility','visible');
        if ( !ie9Inst.hasClass('inst_closed') )
        {
            closeInst ();
        }
        return false;
    });
    
    $('#ie9_bar a.go_inst').click( function() { 
        
        if ( ie9Inst.hasClass('inst_closed') )
        {
            openInst ();
        }
        else
        {
            closeInst ();
        }
        return false;
    });
    
    
    
// team player rating
    $('.team_players dl').hover(
    function() { 
        $(this).addClass('hover');
        $(this).children('.rate').css('display','block'); 
    },
    function() { 
        $(this).removeClass('hover');
        $(this).children('.rate').css('display','none'); 
    });
    
    $('.team_players .rate ul a').click( function() { 
        $(this).parents('ul').addClass('rated');
        return false;
    });
    

// temporary section
/*
$('.com_controls a.comsel').toggle(
    function() {
    $(this).next('.comlist').css({ 'display': 'block' })
    $(this).addClass('s_hover');
},
    function() {
    $(this).next('.comlist').css({ 'display': 'none' })
    $(this).removeClass('s_hover');
}
);
$('.com_controls a.comsel').click(function(e){
    e.stopPropagation();
});
$(document).click(function(){
    var obj = $('a.comsel')
    if ( obj.hasClass('s_hover') )
    {
    obj.next('.comlist').css({ 'display': 'none' })
    obj.removeClass('s_hover');
    }
});
$('.comlist span').hover(
    function() { $(this).addClass('hover'); },
    function() { $(this).removeClass('hover'); });



*/

// drop down hotel select
    $('.select_place input.plsel').focus(
        function() { 
            $(this).next('.pllist').css({ 'display': 'block' });
            $(this).addClass('s_hover');
    });
    
    $('.select_place input.plsel').click(function(e){
        e.stopPropagation();
    });
    
    $(document).click(function(){
        $('.pllist').css({ 'display': 'none' });
        $('.select_place input.plsel').removeClass('s_hover');
    });

    $('.pllist span').click(function(){
        var hot = $(this).attr('title');
        var set = $(this).parents('.pllist').prev('input.text');
        set.attr('value', hot);
        $('.pllist').css({ 'display': 'none' });
        $('.select_place input.plsel').removeClass('s_hover');
        return false;
    });
    
    $('.pllist span').hover(
    function() { $(this).addClass('hover'); },
    function() { $(this).removeClass('hover'); });






// badges tooltip    
    $('#mypage .desc').css('opacity', '0'); 
    function bdescShow () {
        $('.desc', this).css('display','block').animate({ opacity:'1', top:'-76px' }, 200 ); 
    }
    function bdescHide () {
        $('.desc', this).animate({ opacity:'0', top:'-71px' }, 200 , function(){ $(this).css('display','none').css('top','-81px') } ); 
    }
    $('#mypage .badge').hoverIntent
    ({
        sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
        interval: 200, // number = milliseconds for onMouseOver polling interval    
        over: bdescShow, // function = onMouseOver callback (REQUIRED)    
        timeout: 200, // number = milliseconds delay before onMouseOut    
        out: bdescHide // function = onMouseOut callback (REQUIRED)  
     })

//my page follow
/* kod prebaćen
    $('#mypage a#follow').click(function(){
        if ( $(this).hasClass('follow') )
        {
            $(this).removeClass('follow').addClass('follow_clicked');
             
            $('#mypage a#follow').hover(
            function() {  },
            function() { if ( $(this).hasClass('follow_clicked') ) { $(this).removeClass('follow_clicked').addClass('following'); }  });
        }
        else
        {
            $(this).removeClass('following').addClass('follow');
        }
    });
*/

//comments layout helper
    if ( $('#article_addon .comments').length > 0 )
    {
        //alert('yello');
        var arConHeight = $('#article_content').height();
        var arBnnHeight = $('#article .grid_4 .banner_frame').height();
        if ( arConHeight > arBnnHeight ) { var calcHeight = arConHeight - 438 } else { var calcHeight = arBnnHeight - 438 }
        if ( calcHeight <= 0 ) { var calcMargin = calcHeight } else { var calcMargin = 0 }
        $('#article_addon').css('margin-top', calcMargin+'px');
    }
    
    if($('#article_addon .comments').length)
    { 
        $('#article_addon .wrap_comment_item').each(function(i) 
            { 
                var remainder = (i + 1) % 2;
                if(remainder === 0) { $(this).addClass('wci_even') 
            } 
        }); 
    }
    
    
// comment user_scope show/hide
    $('#article_addon a.user span.user_scope').css( 'opacity','0' );
    $('#article_addon a.user').hover(
    function() { $(this).children('span.user_scope').css('display','block').animate({ opacity:'1' }, 100 ); },
    function() { $(this).children('span.user_scope').animate({ opacity:'0' }, 100 ).css('display','none'); });


//article prijavi ispravak
    $('#article_content a.report').click(function(e){
        e.preventDefault()
        $(this).toggleClass('report_active');
        $(this).next('.post_report').slideToggle();
    });
    
    
// drop down sport select
    $('.select_content .liga_controls a.ligasel').click(
    function(e) { 
        e.stopPropagation();
        
        $(".ligalist ul").each(function() {
            var sportContentHeight = $('#sport_tables').height() - 41
            var calcUlBreak = sportContentHeight / 38    
            var floorUlHeight = Math.floor(calcUlBreak) ; /* 12 */
            //console.log(sportContentHeight , calcUlBreak , floorUlHeight)
            
            var list = $(this);
            var size = floorUlHeight;
            var current_size = 0;
        
            list.children().each(function() {
            //console.log(current_size + ": " + $(this).text());
        
            if (++current_size > size) {
                var new_list = $("<ul></ul>").insertAfter(list);
                list = new_list;
                current_size = 1;
            }
            list.append(this);
            });
            
            $(this+':first-child').addClass('first');
        });
        
        $(this).parents('.select_content').find('div.ligalist:visible').slideUp('normal');
        $(this).next('.ligalist').slideDown('normal');
        
        return false;
    });
    
// sidebardrop
    $('.select_content .mini_liga_controls a.ligasel').click(
        function(e) { 
            e.stopPropagation();
            $(this).next('.ligalist').toggle();
            return false;
    });
    

// common    
    $(document).click(function(){
        $('.ligalist').slideUp('normal');
    });
    
    $('.ligalist span').click(function(){
        var hot = $(this).html();
        var set = $(this).parents('.ligalist').prev('a.ligasel');
        set.html(hot);
        $(this).parents('.ligalist').css({ 'display': 'none' });
        return false;
    });
    
    $('.ligalist span').hover(
    function() { $(this).addClass('hover'); },
    function() { $(this).removeClass('hover'); });
        
// mypage select badge        
    $('#mypage .mp_head .badges_holder').hover(
    function(){},
    function(){
        if( $('.wrap_badge a.selected').hasClass('opened') )
        {
            $('.wrap_badge a.selected').trigger('click');
        }
    });
    
    $('.wrap_badge a.selected').click(function(){
        if( $(this).hasClass('opened') )
        {
            $(this).removeClass('opened');
            $(this).parent('.wrap_badge').next('.rest').hide();
        }
        else
        {
            $(this).addClass('opened');
            $(this).parent('.wrap_badge').next('.rest').show();
        }
    });
    
    $('#mypage .rest .badge').click(function(){
        var badge = $(this).attr('class'); 
        $('.wrap_badge a.selected').attr('class', badge+' selected').removeClass('opened');

        var favorite = $('.wrap_badge a.selected').attr('class').split(" ")[1];

        $.ajax({
            type: 'GET',
            url: '/ws/zone24/favorite-badge?badge='+favorite,
            success: function () {
                
            },
            error: function (req, stat, err) {
                
            }
        });

        $('.rest').hide();
    });
    
    $('#mypage .mp_head a.edit_b').click(function () {
        $('.wrap_badge a.selected').trigger('click');
    });
    
// mypage edit links
    $('#mypage .mp_head div.avatar').hover(
    function() { $(this).children('a').show(); },
    function() { $(this).children('a').hide(); });


// mypage discuss last border
    $('#mypage #mp_stream .discuss li:last-child').addClass('last');

// mypage post bundle
    $('#mypage #mp_stream a.more').click(function(){
        $(this).toggleClass('less');
        $(this).prev('#mypage #mp_stream .bundle').slideToggle();
        return false;
    });
    
// mypage discuss bundle    
    $('#mypage #mp_stream .answer a').click(function(){
        $(this).toggleClass('close');
        $(this).parents('.meta').prev('.discuss').slideToggle();
        return false;
    });
    
    $('#mypage #mp_stream .n_answer a').click(function(){
        // $(this).toggleClass('close');
        $(this).parents('.meta').next('.add_comm').slideToggle();
        return false;
    });
     

});    //document ready stop

//live popup window
///////////////////////////////////////////////////////////////////////////////////
// popup start {
function popMeUpScotty(url)
{
   w = window.open (url,
                          "24satapopup",
                          "location=0,status=0,scrollbars=1,width=375,height=600,toolbar=0,menubar=0,directories=0");
     //w.moveTo(0,0);

     w.focus();
}
// popup stop }
///////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////
//anchor slide start
/*******
*** Anchor Slider by Cedric Dugas ***
*** Http://www.position-absolute.com ***
Never have an anchor jumping your content, slide it.
Don't forget to put an id to your anchor !
You can use and modify this script for any project you want, but please leave this comment as credit.
$("a.anchorLink").anchorAnimate();
*****/
jQuery.fn.anchorAnimate = function(settings) {

 settings = jQuery.extend({
 speed : 1000
 }, settings);

 return this.each(function(){
 var caller = this
 $(caller).click(function (event) {
 event.preventDefault()
 var locationHref = window.location.href
 var elementClick = $(caller).attr("href")

 var destination = $(elementClick).offset().top;
 $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
 window.location.hash = elementClick
 });
 return false;
 })
 })
}

// gallery page
    function calculateWinDim ()
    {
        var winHeight = $(window).height();
        
        
        if ( $('#header').length  )
        {
            //console.log('ima headee');
            $('#gallery_page').css('height', winHeight-60);
            $('#gallery_page .place').css('height', winHeight-245);    
        }
        else
        {
            //console.log('nema headee');
            $('#gallery_page').css('height', winHeight);
            $('#gallery_page .place').css('height', winHeight-185);    
            
        }
        
    }
    
    function descPozition () 
    {
        var curr = $('#gallery_page ul.thumbs a.current');
        if ( curr.hasClass('page_gallery_loader') )
        {
            var objWidth = $('#gallery_page .imgholder').width();
            var objHeight = $('#gallery_page .imgholder').height();
            
            $('#gallery_page .wrap_desc').removeClass('pozbot').css('height', objHeight+'px').css('width', objWidth+'px').css('top', '-'+objHeight+'px');
            $('#gallery_page .share').css({'left': ($('#gallery_page .wrap_desc').offset().left - 250)});
            
                    
            $('#gallery_page .wrap_desc').css('visibility','visible');
            $('#gallery_page .share').show();
        }
        else if ( curr.hasClass('page_video_loader') )
        {
            //var objWidth = $('#gallery_page .videoholder').width();
            var objHeight = $('#gallery_page .inner').height();            
            if(objHeight > 600){objHeight = 600};
            var objWidth = Math.floor(parseInt(objHeight * 16 / 9));            
            
            $('.videoholder #player3').css({
                'height': objHeight,
                'width': objWidth,
                'display': 'block',
                'margin': '0 auto'
            })
            
            $('#gallery_page .wrap_desc').addClass('pozbot').css('height', '').css('width', objWidth+'px').css('top', '');
            $('#gallery_page .share').css({'left': ($('#gallery_page #player3').offset().left - 250)});
            
            $('#gallery_page .wrap_desc').css('visibility','visible');
            $('#gallery_page .share').show();
        }        
    };
    
    
    $(document).ready(function() {
        
        /*
        $("#gallery_page .gallery").easySlider({
            prevId: 'prevBtnMasGall',
            nextId: 'nextBtnMasGall'
        });
        
        $('#prevBtnMasGall a, #nextBtnMasGall a').wrapInner('<span></span>');
        */
        //$('#imgHolder').attr('src', $('#imgHolder').attr('rev'));        
        
        calculateWinDim () ;
        if ( $(".place .imgholder").length )
        {
            $("#gallery_page .imgholder").bind("load", function () { descPozition (); });
        }
        else 
        {
            descPozition ();
        }
        
        $(window).bind('resize', resizeWindow);
            function resizeWindow( e ) {
                calculateWinDim () ;
                descPozition () ;
            }
    });





/* slager small live widget 
$(document).ready(function() {
    $('.lf_slide ul li:nth-child(1)').addClass('point').clone().removeClass('point').appendTo('.lf_slide ul');
    $('.lf_slide ul li:nth-child(2)').clone().appendTo('.lf_slide ul');
});

function init () {
    setTimeout( play , 5000 );
}
init ();

function play () {    
    var obj = $('.lf_slide');
    if (obj.length > 0){
        var point = $('.lf_slide li.point');    
        var h = point.outerHeight(); 
        var p  = $('.lf_slide ul').position();
        var pt  = p.top    
        var n = $('.lf_slide li').length-1;
    
        if ( $('.lf_slide ul li:nth-child('+ n +')').hasClass('point') )
        {
            var p = null;
            var pt = null;
            //alert('top');
            $('.lf_slide ul').css('top','0px');
            //alert('00000');
            $('.lf_slide ul').animate({top: -h+pt}, 800 )
            obj.find('li:nth-child(2)').addClass('point');    
            point.eq(0).removeClass('point');
        }
        else
        {
            //alert(-ulH);
            //alert(pt);
            $('.lf_slide ul').animate({top: -h+pt}, 800 )    
            point.next().addClass('point');    
            point.eq(0).removeClass('point');
        }
    }
    init ();
}

*/